Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECO-4940] NS_SWIFT_SENDABLE to every type that has a docstring #1963

Merged
merged 7 commits into from
Sep 5, 2024

Conversation

maratal
Copy link
Collaborator

@maratal maratal commented Aug 23, 2024

I've added NS_SWIFT_SENDABLE to every type that has a docstring and their accompanied enums and params types.

Closes #1962

Summary by CodeRabbit

  • New Features

    • Added NS_SWIFT_SENDABLE attribute to multiple interfaces, enhancing compatibility with Swift's concurrency model for safer multi-threaded use.
  • Improvements

    • Improved interoperability of various classes with Swift, ensuring adherence to concurrency safety requirements.
    • Modified properties in ARTDeviceDetails and ARTDevicePushDetails to be read-only, enhancing encapsulation.
    • Implemented immutability controls for ARTChannelOptions, reinforcing data integrity.
    • Enhanced error handling capabilities in Objective-C with the new tryInObjC function.
    • Added a new test to verify the immutability of ARTRealtimeChannelOptions, ensuring robust channel configuration.

Copy link

coderabbitai bot commented Aug 23, 2024

Walkthrough

The updates introduce the NS_SWIFT_SENDABLE annotation to various Objective-C interfaces in the Ably SDK, indicating that instances can be safely used across Swift concurrency contexts. Additionally, private headers and read-only properties are added to enhance encapsulation and manage mutability, ensuring better control over the state of objects.

Changes

File(s) Change Summary
Source/include/Ably/ARTConnectionDetails.h, Source/include/Ably/ARTRestChannels.h, Source/include/Ably/ARTRealtimeChannels.h, Source/include/Ably/ARTDevicePushDetails.h Added NS_SWIFT_SENDABLE to enhance concurrency safety for respective interfaces.
Source/include/Ably/ARTDeviceDetails.h Changed properties to read-only to enhance encapsulation and immutability.
Ably.xcodeproj/project.pbxproj, Source/Ably.modulemap, Source/PrivateHeaders/... Added private headers to improve encapsulation and internal management of device details.
Source/ARTDevicePushDetails.m, Source/ARTJsonLikeEncoder.m Introduced mechanisms to access private properties and enhance functionality.
Test/Tests/RealtimeClientChannelTests.swift Added a test to verify immutability of ARTRealtimeChannelOptions.

Assessment against linked issues

Objective Addressed Explanation
Add Swift concurrency annotations to improve thread safety (ECO-4940, #1962)

🐰 In fields so wide, where bunnies hop,
Swift concurrency now has a safer crop.
With NS_SWIFT_SENDABLE, our paths align,
In harmony, Objective-C and Swift entwine.
Celebrate the change, let’s all take a leap,
For safe threads await, in code we keep! 🌼

Tip

We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 23, 2024 10:43 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 23, 2024 10:47 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 55ad795 and 0ac6b31.

Files selected for processing (43)
  • Source/PrivateHeaders/Ably/ARTAttachRequestParams.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTChannelStateChangeParams.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTConnectionStateChangeParams.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTTestClientOptions.h (1 hunks)
  • Source/include/Ably/ARTAuth.h (1 hunks)
  • Source/include/Ably/ARTAuthDetails.h (1 hunks)
  • Source/include/Ably/ARTAuthOptions.h (1 hunks)
  • Source/include/Ably/ARTChannel.h (1 hunks)
  • Source/include/Ably/ARTChannelOptions.h (1 hunks)
  • Source/include/Ably/ARTChannels.h (1 hunks)
  • Source/include/Ably/ARTClientOptions.h (1 hunks)
  • Source/include/Ably/ARTConnection.h (1 hunks)
  • Source/include/Ably/ARTConnectionDetails.h (1 hunks)
  • Source/include/Ably/ARTDataQuery.h (3 hunks)
  • Source/include/Ably/ARTDeviceDetails.h (1 hunks)
  • Source/include/Ably/ARTDeviceIdentityTokenDetails.h (1 hunks)
  • Source/include/Ably/ARTDevicePushDetails.h (1 hunks)
  • Source/include/Ably/ARTEventEmitter.h (1 hunks)
  • Source/include/Ably/ARTHTTPPaginatedResponse.h (1 hunks)
  • Source/include/Ably/ARTLocalDevice.h (1 hunks)
  • Source/include/Ably/ARTMessage.h (1 hunks)
  • Source/include/Ably/ARTPaginatedResult.h (1 hunks)
  • Source/include/Ably/ARTPresence.h (1 hunks)
  • Source/include/Ably/ARTPresenceMessage.h (2 hunks)
  • Source/include/Ably/ARTPush.h (1 hunks)
  • Source/include/Ably/ARTPushAdmin.h (1 hunks)
  • Source/include/Ably/ARTPushChannel.h (1 hunks)
  • Source/include/Ably/ARTPushChannelSubscription.h (1 hunks)
  • Source/include/Ably/ARTPushChannelSubscriptions.h (1 hunks)
  • Source/include/Ably/ARTPushDeviceRegistrations.h (1 hunks)
  • Source/include/Ably/ARTRealtime.h (1 hunks)
  • Source/include/Ably/ARTRealtimeChannel.h (1 hunks)
  • Source/include/Ably/ARTRealtimeChannelOptions.h (2 hunks)
  • Source/include/Ably/ARTRealtimePresence.h (2 hunks)
  • Source/include/Ably/ARTRest.h (1 hunks)
  • Source/include/Ably/ARTRestChannel.h (1 hunks)
  • Source/include/Ably/ARTRestPresence.h (2 hunks)
  • Source/include/Ably/ARTStats.h (10 hunks)
  • Source/include/Ably/ARTStatus.h (3 hunks)
  • Source/include/Ably/ARTTokenDetails.h (1 hunks)
  • Source/include/Ably/ARTTokenParams.h (1 hunks)
  • Source/include/Ably/ARTTokenRequest.h (1 hunks)
  • Source/include/Ably/ARTTypes.h (14 hunks)
Additional comments not posted (72)
Source/include/Ably/ARTPresence.h (1)

10-10: NS_SWIFT_SENDABLE annotation added to ARTPresence.

The addition of the NS_SWIFT_SENDABLE annotation enhances concurrency support for Swift users by indicating that instances of ARTPresence can be safely used across concurrency domains.

Source/include/Ably/ARTAuthDetails.h (1)

8-8: NS_SWIFT_SENDABLE annotation added to ARTAuthDetails.

The addition of the NS_SWIFT_SENDABLE annotation enhances concurrency support for Swift users by indicating that instances of ARTAuthDetails can be safely used across concurrency domains.

Source/include/Ably/ARTLocalDevice.h (1)

11-11: NS_SWIFT_SENDABLE annotation added to ARTLocalDevice.

The addition of the NS_SWIFT_SENDABLE annotation enhances concurrency support for Swift users by indicating that instances of ARTLocalDevice can be safely used across concurrency domains.

Source/include/Ably/ARTDevicePushDetails.h (1)

10-10: NS_SWIFT_SENDABLE annotation added successfully.

The addition of NS_SWIFT_SENDABLE to ARTDevicePushDetails enhances its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.

Source/include/Ably/ARTChannelOptions.h (1)

11-11: NS_SWIFT_SENDABLE annotation added successfully.

The addition of NS_SWIFT_SENDABLE to ARTChannelOptions enhances its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.

Source/include/Ably/ARTDeviceIdentityTokenDetails.h (1)

8-8: NS_SWIFT_SENDABLE annotation added successfully.

The addition of NS_SWIFT_SENDABLE to ARTDeviceIdentityTokenDetails enhances its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.

Source/PrivateHeaders/Ably/ARTConnectionStateChangeParams.h (1)

13-13: Approved: Addition of NS_SWIFT_SENDABLE.

The addition of the NS_SWIFT_SENDABLE attribute to the ARTConnectionStateChangeParams interface is appropriate and aligns with the PR objectives to enhance Swift concurrency compatibility.

Source/include/Ably/ARTRealtimeChannelOptions.h (1)

8-8: Approved: Addition of NS_SWIFT_SENDABLE.

The addition of the NS_SWIFT_SENDABLE attribute to both ARTChannelMode and ARTRealtimeChannelOptions is appropriate and aligns with the PR objectives to enhance Swift concurrency compatibility.

Also applies to: 33-33

Source/include/Ably/ARTDeviceDetails.h (1)

11-11: Approved: Addition of NS_SWIFT_SENDABLE.

The addition of the NS_SWIFT_SENDABLE attribute to the ARTDeviceDetails interface is appropriate and aligns with the PR objectives to enhance Swift concurrency compatibility.

Source/include/Ably/ARTPushAdmin.h (1)

30-30: NS_SWIFT_SENDABLE annotation added successfully.

The addition of NS_SWIFT_SENDABLE to the ARTPushAdmin interface enhances its compatibility with Swift's concurrency model. This change is appropriate for ensuring thread safety and interoperability.

Source/include/Ably/ARTPushChannelSubscription.h (1)

8-8: NS_SWIFT_SENDABLE annotation added successfully.

The addition of NS_SWIFT_SENDABLE to the ARTPushChannelSubscription interface enhances its compatibility with Swift's concurrency model. This change is appropriate for ensuring thread safety and interoperability.

Source/PrivateHeaders/Ably/ARTAttachRequestParams.h (1)

11-11: NS_SWIFT_SENDABLE annotation added successfully.

The addition of NS_SWIFT_SENDABLE to the ARTAttachRequestParams interface enhances its compatibility with Swift's concurrency model. This change is appropriate for ensuring thread safety and interoperability.

Source/PrivateHeaders/Ably/ARTTestClientOptions.h (1)

13-13: NS_SWIFT_SENDABLE annotation added successfully.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTTestClientOptions interface enhances Swift concurrency compatibility. This change is aligned with the PR objectives and does not affect existing functionality.

Source/include/Ably/ARTChannels.h (1)

10-10: NS_SWIFT_SENDABLE annotation added successfully.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTChannels interface enhances Swift concurrency compatibility. This change is aligned with the PR objectives and does not affect existing functionality.

Source/include/Ably/ARTHTTPPaginatedResponse.h (1)

10-10: NS_SWIFT_SENDABLE annotation added successfully.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTHTTPPaginatedResponse interface enhances Swift concurrency compatibility. This change is aligned with the PR objectives and does not affect existing functionality.

Source/include/Ably/ARTDataQuery.h (1)

8-8: NS_SWIFT_SENDABLE annotation added.

The addition of NS_SWIFT_SENDABLE to ARTQueryDirection, ARTDataQuery, and ARTRealtimeHistoryQuery enhances Swift concurrency compatibility.

Also applies to: 17-17, 45-45

Source/include/Ably/ARTPaginatedResult.h (1)

11-11: NS_SWIFT_SENDABLE annotation added.

The addition of NS_SWIFT_SENDABLE to ARTPaginatedResult enhances Swift concurrency compatibility.

Source/include/Ably/ARTRestChannel.h (1)

49-49: NS_SWIFT_SENDABLE annotation added.

The addition of NS_SWIFT_SENDABLE to ARTRestChannel enhances Swift concurrency compatibility.

Source/PrivateHeaders/Ably/ARTChannelStateChangeParams.h (1)

14-14: NS_SWIFT_SENDABLE Annotation Added.

The addition of NS_SWIFT_SENDABLE to the ARTChannelStateChangeParams interface enhances its compatibility with Swift's concurrency model. This change aligns with the PR objectives and does not affect existing functionality.

Source/include/Ably/ARTMessage.h (1)

12-12: NS_SWIFT_SENDABLE Annotation Added.

The addition of NS_SWIFT_SENDABLE to the ARTMessage interface enhances its compatibility with Swift's concurrency model. This change aligns with the PR objectives and does not affect existing functionality.

Source/include/Ably/ARTPresenceMessage.h (2)

7-7: NS_SWIFT_SENDABLE Annotation Added to Enumeration.

The addition of NS_SWIFT_SENDABLE to the ARTPresenceAction enumeration enhances its compatibility with Swift's concurrency model. This change aligns with the PR objectives and does not affect existing functionality.


39-39: NS_SWIFT_SENDABLE Annotation Added to Interface.

The addition of NS_SWIFT_SENDABLE to the ARTPresenceMessage interface enhances its compatibility with Swift's concurrency model. This change aligns with the PR objectives and does not affect existing functionality.

Source/include/Ably/ARTPushDeviceRegistrations.h (1)

64-64: Addition of NS_SWIFT_SENDABLE annotation is appropriate.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTPushDeviceRegistrations interface aligns with the PR objectives of enhancing Swift concurrency compatibility. This change does not affect existing functionality and is a positive step towards ensuring thread safety.

Source/include/Ably/ARTTokenParams.h (1)

13-13: Addition of NS_SWIFT_SENDABLE annotation is appropriate.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTTokenParams interface aligns with the PR objectives of enhancing Swift concurrency compatibility. This change does not affect existing functionality and is a positive step towards ensuring thread safety.

Source/include/Ably/ARTPushChannelSubscriptions.h (1)

65-65: Addition of NS_SWIFT_SENDABLE annotation is appropriate.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTPushChannelSubscriptions interface aligns with the PR objectives of enhancing Swift concurrency compatibility. This change does not affect existing functionality and is a positive step towards ensuring thread safety.

Source/include/Ably/ARTPushChannel.h (1)

86-86: NS_SWIFT_SENDABLE Annotation Added

The addition of the NS_SWIFT_SENDABLE annotation to the ARTPushChannel interface is appropriate and enhances compatibility with Swift's concurrency model. No further changes are necessary.

Source/include/Ably/ARTTokenDetails.h (1)

11-11: NS_SWIFT_SENDABLE Annotation Added

The addition of the NS_SWIFT_SENDABLE annotation to the ARTTokenDetails interface is appropriate and enhances compatibility with Swift's concurrency model. No further changes are necessary.

Source/include/Ably/ARTConnectionDetails.h (1)

8-8: NS_SWIFT_SENDABLE Annotation Added

The addition of the NS_SWIFT_SENDABLE annotation to the ARTConnectionDetails interface is appropriate and enhances compatibility with Swift's concurrency model. No further changes are necessary.

Source/include/Ably/ARTRestPresence.h (2)

13-13: NS_SWIFT_SENDABLE annotation added to ARTPresenceQuery.

The addition of NS_SWIFT_SENDABLE to ARTPresenceQuery is appropriate for enhancing Swift concurrency compatibility.


82-82: NS_SWIFT_SENDABLE annotation added to ARTRestPresence.

The addition of NS_SWIFT_SENDABLE to ARTRestPresence is appropriate for enhancing Swift concurrency compatibility.

Source/include/Ably/ARTTokenRequest.h (1)

12-12: NS_SWIFT_SENDABLE annotation added to ARTTokenRequest.

The addition of NS_SWIFT_SENDABLE to ARTTokenRequest is appropriate for enhancing Swift concurrency compatibility.

Source/include/Ably/ARTChannel.h (1)

82-82: NS_SWIFT_SENDABLE annotation added to ARTChannel.

The addition of NS_SWIFT_SENDABLE to ARTChannel is appropriate for enhancing Swift concurrency compatibility.

Source/include/Ably/ARTConnection.h (1)

83-83: NS_SWIFT_SENDABLE annotation added.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTConnection interface is appropriate for enhancing Swift concurrency compatibility. No issues found.

Source/include/Ably/ARTRealtime.h (1)

107-107: NS_SWIFT_SENDABLE annotation added.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTRealtime interface is appropriate for enhancing Swift concurrency compatibility. No issues found.

Source/include/Ably/ARTRest.h (1)

102-102: NS_SWIFT_SENDABLE annotation added.

The addition of the NS_SWIFT_SENDABLE annotation to the ARTRest interface is appropriate for enhancing Swift concurrency compatibility. No issues found.

Source/include/Ably/ARTPush.h (1)

114-114: NS_SWIFT_SENDABLE Annotation Added to ARTPush

The addition of the NS_SWIFT_SENDABLE annotation to the ARTPush interface is appropriate and aligns with the objective of enhancing interoperability with Swift's concurrency model. This change ensures that instances of ARTPush can be safely used across Swift concurrency domains.

Source/include/Ably/ARTAuth.h (1)

91-91: NS_SWIFT_SENDABLE Annotation Added to ARTAuth

The addition of the NS_SWIFT_SENDABLE annotation to the ARTAuth interface is appropriate and aligns with the objective of enhancing interoperability with Swift's concurrency model. This change ensures that instances of ARTAuth can be safely used across Swift concurrency domains.

Source/include/Ably/ARTAuthOptions.h (1)

21-21: NS_SWIFT_SENDABLE Annotation Added to ARTAuthOptions

The addition of the NS_SWIFT_SENDABLE annotation to the ARTAuthOptions interface is appropriate and aligns with the objective of enhancing interoperability with Swift's concurrency model. This change ensures that instances of ARTAuthOptions can be safely used across Swift concurrency domains.

Source/include/Ably/ARTEventEmitter.h (2)

26-26: NS_SWIFT_SENDABLE annotation added to ARTEventListener.

The addition of NS_SWIFT_SENDABLE to ARTEventListener is appropriate for Swift concurrency compatibility.


33-33: NS_SWIFT_SENDABLE annotation added to ARTEventEmitter.

The addition of NS_SWIFT_SENDABLE to ARTEventEmitter is appropriate for Swift concurrency compatibility.

Source/include/Ably/ARTRealtimeChannel.h (1)

152-152: NS_SWIFT_SENDABLE annotation added to ARTRealtimeChannel.

The addition of NS_SWIFT_SENDABLE to ARTRealtimeChannel is appropriate for Swift concurrency compatibility.

Source/include/Ably/ARTClientOptions.h (1)

15-15: NS_SWIFT_SENDABLE annotation added to ARTClientOptions.

The addition of NS_SWIFT_SENDABLE to ARTClientOptions is appropriate for Swift concurrency compatibility.

Source/include/Ably/ARTStatus.h (3)

30-30: Addition of NS_SWIFT_SENDABLE to ARTErrorCode.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTErrorCode enumeration, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.


193-193: Addition of NS_SWIFT_SENDABLE to ARTErrorInfo.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTErrorInfo interface. This enhances its usability in Swift concurrency contexts and aligns with the PR objectives.


262-262: Addition of NS_SWIFT_SENDABLE to ARTStatus.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatus interface. This change improves its integration with Swift's concurrency model and is consistent with the PR objectives.

Source/include/Ably/ARTRealtimePresence.h (2)

13-13: Addition of NS_SWIFT_SENDABLE to ARTRealtimePresenceQuery.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTRealtimePresenceQuery interface, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.


221-221: Addition of NS_SWIFT_SENDABLE to ARTRealtimePresence.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTRealtimePresence interface. This enhances its usability in Swift concurrency contexts and aligns with the PR objectives.

Source/include/Ably/ARTStats.h (10)

10-10: Addition of NS_SWIFT_SENDABLE to ARTStatsGranularity.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsGranularity enumeration, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.


33-33: Addition of NS_SWIFT_SENDABLE to ARTStatsQuery.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsQuery interface, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.


46-46: Addition of NS_SWIFT_SENDABLE to ARTStatsMessageCount.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsMessageCount interface. This enhances its usability in Swift concurrency contexts and aligns with the PR objectives.


74-74: Addition of NS_SWIFT_SENDABLE to ARTStatsMessageTypes.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsMessageTypes interface, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.


108-108: Addition of NS_SWIFT_SENDABLE to ARTStatsMessageTraffic.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsMessageTraffic interface. This enhances its usability in Swift concurrency contexts and aligns with the PR objectives.


148-148: Addition of NS_SWIFT_SENDABLE to ARTStatsResourceCount.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsResourceCount interface, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.


194-194: Addition of NS_SWIFT_SENDABLE to ARTStatsConnectionTypes.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsConnectionTypes interface. This enhances its usability in Swift concurrency contexts and aligns with the PR objectives.


228-228: Addition of NS_SWIFT_SENDABLE to ARTStatsRequestCount.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsRequestCount interface, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.


262-262: Addition of NS_SWIFT_SENDABLE to ARTStatsPushCount.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStatsPushCount interface. This enhances its usability in Swift concurrency contexts and aligns with the PR objectives.


314-314: Addition of NS_SWIFT_SENDABLE to ARTStats.

The NS_SWIFT_SENDABLE annotation has been correctly added to the ARTStats interface, enhancing its compatibility with Swift's concurrency model. This change is appropriate and aligns with the PR objectives.

Source/include/Ably/ARTTypes.h (15)

37-37: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTAuthentication is appropriate.


47-47: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTAuthMethod is appropriate.


56-56: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTRealtimeConnectionState is appropriate.


98-98: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTRealtimeConnectionEvent is appropriate.


120-120: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTRealtimeChannelState is appropriate.


158-158: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTChannelEvent is appropriate.


178-178: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTDataQueryError is appropriate.


188-188: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTRealtimeHistoryError is appropriate.


194-194: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTCustomRequestError is appropriate.


233-233: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTConnectionStateChange is appropriate.


277-277: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTChannelStateChange is appropriate.


323-323: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTChannelMetrics is appropriate.


369-369: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTChannelOccupancy is appropriate.


385-385: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTChannelStatus is appropriate.


406-406: LGTM!

The addition of NS_SWIFT_SENDABLE to ARTChannelDetails is appropriate.

@lawrence-forooghian
Copy link
Collaborator

Please can you mention the resolved issue in the commit message?

Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m curious why you've annotated some of the types in PrivateHeaders?

… their accompanied enums and params types (issue #1962).
@maratal maratal force-pushed the fix/1962-swift-concurrency-annotations branch from 0ac6b31 to de49b67 Compare August 24, 2024 17:39
@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 24, 2024 17:39 Inactive
@maratal
Copy link
Collaborator Author

maratal commented Aug 24, 2024

Please can you mention the resolved issue in the commit message?

Done.

I’m curious why you've annotated some of the types in PrivateHeaders?

Yeah, Xcode doesn't show real file path, so somehow those ended up there, sorry, fixed in de49b67

@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 24, 2024 17:42 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0ac6b31 and de49b67.

Files selected for processing (39)
  • Source/include/Ably/ARTAuth.h (1 hunks)
  • Source/include/Ably/ARTAuthDetails.h (1 hunks)
  • Source/include/Ably/ARTAuthOptions.h (1 hunks)
  • Source/include/Ably/ARTChannel.h (1 hunks)
  • Source/include/Ably/ARTChannelOptions.h (1 hunks)
  • Source/include/Ably/ARTChannels.h (1 hunks)
  • Source/include/Ably/ARTClientOptions.h (1 hunks)
  • Source/include/Ably/ARTConnection.h (1 hunks)
  • Source/include/Ably/ARTConnectionDetails.h (1 hunks)
  • Source/include/Ably/ARTDataQuery.h (3 hunks)
  • Source/include/Ably/ARTDeviceDetails.h (1 hunks)
  • Source/include/Ably/ARTDeviceIdentityTokenDetails.h (1 hunks)
  • Source/include/Ably/ARTDevicePushDetails.h (1 hunks)
  • Source/include/Ably/ARTEventEmitter.h (1 hunks)
  • Source/include/Ably/ARTHTTPPaginatedResponse.h (1 hunks)
  • Source/include/Ably/ARTLocalDevice.h (1 hunks)
  • Source/include/Ably/ARTMessage.h (1 hunks)
  • Source/include/Ably/ARTPaginatedResult.h (1 hunks)
  • Source/include/Ably/ARTPresence.h (1 hunks)
  • Source/include/Ably/ARTPresenceMessage.h (2 hunks)
  • Source/include/Ably/ARTPush.h (1 hunks)
  • Source/include/Ably/ARTPushAdmin.h (1 hunks)
  • Source/include/Ably/ARTPushChannel.h (1 hunks)
  • Source/include/Ably/ARTPushChannelSubscription.h (1 hunks)
  • Source/include/Ably/ARTPushChannelSubscriptions.h (1 hunks)
  • Source/include/Ably/ARTPushDeviceRegistrations.h (1 hunks)
  • Source/include/Ably/ARTRealtime.h (1 hunks)
  • Source/include/Ably/ARTRealtimeChannel.h (1 hunks)
  • Source/include/Ably/ARTRealtimeChannelOptions.h (2 hunks)
  • Source/include/Ably/ARTRealtimePresence.h (2 hunks)
  • Source/include/Ably/ARTRest.h (1 hunks)
  • Source/include/Ably/ARTRestChannel.h (1 hunks)
  • Source/include/Ably/ARTRestPresence.h (2 hunks)
  • Source/include/Ably/ARTStats.h (10 hunks)
  • Source/include/Ably/ARTStatus.h (3 hunks)
  • Source/include/Ably/ARTTokenDetails.h (1 hunks)
  • Source/include/Ably/ARTTokenParams.h (1 hunks)
  • Source/include/Ably/ARTTokenRequest.h (1 hunks)
  • Source/include/Ably/ARTTypes.h (14 hunks)
Files skipped from review due to trivial changes (15)
  • Source/include/Ably/ARTAuthDetails.h
  • Source/include/Ably/ARTChannelOptions.h
  • Source/include/Ably/ARTConnectionDetails.h
  • Source/include/Ably/ARTDataQuery.h
  • Source/include/Ably/ARTLocalDevice.h
  • Source/include/Ably/ARTPaginatedResult.h
  • Source/include/Ably/ARTPresence.h
  • Source/include/Ably/ARTPresenceMessage.h
  • Source/include/Ably/ARTPushAdmin.h
  • Source/include/Ably/ARTRealtime.h
  • Source/include/Ably/ARTRest.h
  • Source/include/Ably/ARTRestChannel.h
  • Source/include/Ably/ARTStatus.h
  • Source/include/Ably/ARTTokenParams.h
  • Source/include/Ably/ARTTypes.h
Files skipped from review as they are similar to previous changes (24)
  • Source/include/Ably/ARTAuth.h
  • Source/include/Ably/ARTAuthOptions.h
  • Source/include/Ably/ARTChannel.h
  • Source/include/Ably/ARTChannels.h
  • Source/include/Ably/ARTClientOptions.h
  • Source/include/Ably/ARTConnection.h
  • Source/include/Ably/ARTDeviceDetails.h
  • Source/include/Ably/ARTDeviceIdentityTokenDetails.h
  • Source/include/Ably/ARTDevicePushDetails.h
  • Source/include/Ably/ARTEventEmitter.h
  • Source/include/Ably/ARTHTTPPaginatedResponse.h
  • Source/include/Ably/ARTMessage.h
  • Source/include/Ably/ARTPush.h
  • Source/include/Ably/ARTPushChannel.h
  • Source/include/Ably/ARTPushChannelSubscription.h
  • Source/include/Ably/ARTPushChannelSubscriptions.h
  • Source/include/Ably/ARTPushDeviceRegistrations.h
  • Source/include/Ably/ARTRealtimeChannel.h
  • Source/include/Ably/ARTRealtimeChannelOptions.h
  • Source/include/Ably/ARTRealtimePresence.h
  • Source/include/Ably/ARTRestPresence.h
  • Source/include/Ably/ARTStats.h
  • Source/include/Ably/ARTTokenDetails.h
  • Source/include/Ably/ARTTokenRequest.h

…queue` and enums (they transformed into swift enums which are sendable).
@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 24, 2024 18:47 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 24, 2024 18:50 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between de49b67 and 401dd03.

Files selected for processing (8)
  • Source/include/Ably/ARTDataQuery.h (1 hunks)
  • Source/include/Ably/ARTPresenceMessage.h (1 hunks)
  • Source/include/Ably/ARTRealtimeChannelOptions.h (1 hunks)
  • Source/include/Ably/ARTRealtimePresence.h (1 hunks)
  • Source/include/Ably/ARTRestPresence.h (1 hunks)
  • Source/include/Ably/ARTStats.h (1 hunks)
  • Source/include/Ably/ARTStatus.h (1 hunks)
  • Source/include/Ably/ARTTypes.h (8 hunks)
Files skipped from review due to trivial changes (3)
  • Source/include/Ably/ARTDataQuery.h
  • Source/include/Ably/ARTPresenceMessage.h
  • Source/include/Ably/ARTStats.h
Files skipped from review as they are similar to previous changes (5)
  • Source/include/Ably/ARTRealtimeChannelOptions.h
  • Source/include/Ably/ARTRealtimePresence.h
  • Source/include/Ably/ARTRestPresence.h
  • Source/include/Ably/ARTStatus.h
  • Source/include/Ably/ARTTypes.h

…perties and `ARTRestChannels` calls only methods of a sendable object).
@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 25, 2024 09:34 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 25, 2024 09:37 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 401dd03 and 9048f94.

Files selected for processing (2)
  • Source/include/Ably/ARTConnectionDetails.h (1 hunks)
  • Source/include/Ably/ARTRestChannels.h (1 hunks)
Files skipped from review due to trivial changes (1)
  • Source/include/Ably/ARTConnectionDetails.h
Additional comments not posted (1)
Source/include/Ably/ARTRestChannels.h (1)

19-19: Approved addition of NS_SWIFT_SENDABLE.

The addition of the NS_SWIFT_SENDABLE annotation is a crucial enhancement for Swift concurrency compatibility. This change aligns well with the objectives outlined in the PR and the linked issue.

@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 30, 2024 10:58 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 30, 2024 11:03 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
Source/ARTLocalDevice.m (1)

2-2: The import statement references a non-existent file.

The import of ARTDeviceDetails+Private.h in ARTLocalDevice.m is referencing a file that does not exist in the repository. This import is likely unnecessary and should be reviewed to prevent potential compilation errors. Please verify the necessity of this import and update it accordingly.

  • File: Source/ARTLocalDevice.m
  • Line: 2
Analysis chain

Verify the necessity and usage of the new import.

The import of ARTDeviceDetails+Private.h has been added. Please ensure that it is necessary for the functionality within ARTLocalDevice.m and that it does not introduce redundancy or conflicts with other imports.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ARTDeviceDetails+Private.h` in `ARTLocalDevice.m`.

# Test: Search for usage of members or methods from `ARTDeviceDetails+Private.h` in `ARTLocalDevice.m`.
rg --type objc -A 5 $'ARTDeviceDetails' Source/ARTLocalDevice.m

Length of output: 254


Script:

#!/bin/bash
# Description: Search for specific methods or properties from `ARTDeviceDetails+Private.h` in `ARTLocalDevice.m`.

# Find the methods or properties declared in `ARTDeviceDetails+Private.h`.
rg --type objc --no-filename --no-heading '^\s*[-+]' Source/ARTDeviceDetails+Private.h > methods.txt

# Search for these methods or properties in `ARTLocalDevice.m`.
while IFS= read -r method; do
  echo "Searching for usage of: $method"
  rg --type objc "$method" Source/ARTLocalDevice.m
done < methods.txt

Length of output: 186

Source/ARTJsonLikeEncoder.m (1)

20-20: Remove the unnecessary import statement.

The file ARTDeviceDetails+Private.h does not exist in the repository, making the import statement in ARTJsonLikeEncoder.m unnecessary. Please remove this import to avoid potential compilation issues.

  • File: Source/ARTJsonLikeEncoder.m
  • Line: #import "ARTDeviceDetails+Private.h"
Analysis chain

Verify the necessity and usage of the new import.

The import of ARTDeviceDetails+Private.h has been added. Please ensure that it is necessary for the functionality within ARTJsonLikeEncoder.m and that it does not introduce redundancy or conflicts with other imports.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ARTDeviceDetails+Private.h` in `ARTJsonLikeEncoder.m`.

# Test: Search for usage of members or methods from `ARTDeviceDetails+Private.h` in `ARTJsonLikeEncoder.m`.
rg --type objc -A 5 $'ARTDeviceDetails' Source/ARTJsonLikeEncoder.m

Length of output: 2734


Script:

#!/bin/bash
# Description: Check the contents of `ARTDeviceDetails+Private.h` and verify their usage in `ARTJsonLikeEncoder.m`.

# Step 1: Display the contents of `ARTDeviceDetails+Private.h` to identify private members or methods.
fd 'ARTDeviceDetails+Private.h' -x cat {}

# Step 2: Search for usage of any identified private members or methods in `ARTJsonLikeEncoder.m`.
# This step will be executed after reviewing the contents of the private header.

Length of output: 43


Script:

#!/bin/bash
# Description: Verify the existence of `ARTDeviceDetails+Private.h` and display its contents.

# Step 1: Search for the file `ARTDeviceDetails+Private.h` in the repository.
fd 'ARTDeviceDetails+Private.h'

# Step 2: If found, display its contents.
fd 'ARTDeviceDetails+Private.h' -x cat {}

Length of output: 75

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9048f94 and f9684a5.

Files selected for processing (16)
  • Ably.xcodeproj/project.pbxproj (10 hunks)
  • Source/ARTChannel.m (2 hunks)
  • Source/ARTChannelOptions.m (2 hunks)
  • Source/ARTDeviceDetails.m (1 hunks)
  • Source/ARTJsonLikeEncoder.m (1 hunks)
  • Source/ARTLocalDevice.m (1 hunks)
  • Source/ARTRealtimeChannelOptions.m (1 hunks)
  • Source/Ably.modulemap (1 hunks)
  • Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h (1 hunks)
  • Source/include/Ably/ARTDeviceDetails.h (1 hunks)
  • Source/include/Ably/ARTLocalDevice.h (2 hunks)
  • Test/Test Utilities/NSObject+TestSuite.h (1 hunks)
  • Test/Test Utilities/NSObject+TestSuite.m (1 hunks)
  • Test/Tests/RealtimeClientChannelTests.swift (1 hunks)
Files skipped from review due to trivial changes (1)
  • Ably.xcodeproj/project.pbxproj
Additional comments not posted (17)
Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h (1)

1-8: Review of New File: ARTChannelOptions+Private.h

The introduction of the frozen property with a custom getter is a good practice for boolean properties in Objective-C, enhancing code readability. The file structure adheres to conventions for private headers, and necessary imports are included.

The changes are approved.

Verification successful

Verification Successful: Proper Usage of frozen Property

The frozen property is used correctly in the codebase to enforce immutability by throwing exceptions when modifications are attempted after the options have been passed to a receiver. This aligns with the intended design and purpose of the property.

  • Verified usage in Source/ARTRealtimeChannelOptions.m
  • Verified usage in Source/ARTChannelOptions.m
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `frozen` property in the SDK.

# Test: Search for the usage of the `frozen` property. Expect: Proper usage in the SDK.
rg --type objc -A 5 $'isFrozen'

Length of output: 1847

Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h (1)

1-19: Review of New File: ARTDeviceDetails+Private.h

The introduction of several properties with readwrite attributes in a private header is appropriate, allowing internal modifications. The use of nullable and NSDictionary types is correctly applied, and the nullability macros are used properly.

The changes are approved.

Source/include/Ably/ARTLocalDevice.h (1)

Line range hint 1-22: Review of Changes in ARTLocalDevice.h

The addition of the NS_SWIFT_SENDABLE attribute to the ARTLocalDevice interface is a significant enhancement for Swift concurrency compatibility. The file structure adheres to conventions for public headers, and necessary imports are included.

The changes are approved.

Verification successful

NS_SWIFT_SENDABLE Attribute Usage Verified
The NS_SWIFT_SENDABLE attribute is used consistently across the SDK, including in the ARTLocalDevice interface, enhancing Swift concurrency compatibility as intended. The review comment is verified as correct.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `NS_SWIFT_SENDABLE` attribute in the SDK.

# Test: Search for the usage of the `NS_SWIFT_SENDABLE` attribute. Expect: Proper usage in the SDK.
rg --type objc -A 5 $'NS_SWIFT_SENDABLE'

Length of output: 13583

Source/ARTChannelOptions.m (3)

6-6: Instance variable _cipher addition approved.

The addition of _cipher enhances the class's functionality by allowing it to store cipher parameters.


20-22: Getter method for _cipher approved.

The method correctly returns the value of _cipher.


24-31: Setter method for _cipher approved with commendation for robust exception handling.

The method correctly handles the isFrozen state by throwing an exception if an attempt is made to modify the cipher parameters after the object is frozen. This is crucial for maintaining object integrity in multi-threaded environments.

Source/ARTRealtimeChannelOptions.m (3)

5-6: Instance variables _params and _modes addition approved.

The addition of _params and _modes enhances the class's encapsulation by allowing it to store channel options securely.


9-11: Getter methods for _params and _modes approved.

The methods correctly return the values of _params and _modes.

Also applies to: 22-24


13-20: Setter methods for _params and _modes approved with commendation for robust exception handling.

The methods correctly handle the isFrozen state by throwing exceptions if an attempt is made to modify the parameters or modes after the object is frozen. This is crucial for maintaining object integrity in multi-threaded environments.

Also applies to: 26-33

Source/include/Ably/ARTDeviceDetails.h (1)

16-16: Changes to properties approved.

The changes to make the properties id, clientId, platform, formFactor, metadata, and push read-only are approved. These changes enhance encapsulation and promote immutability, aligning with best practices in object-oriented design.

Also applies to: 21-21, 26-26, 31-31, 36-36, 41-41

Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h (1)

22-22: Approve the addition of the secret property.

The addition of the secret property to ARTLocalDevice is a positive change for enhancing device-specific security features. Ensure that the integration of this property with existing functionalities is thoroughly tested.

The code changes are approved.

Run the following script to verify the integration of the new property:

Verification successful

The secret property is well-integrated with existing functionalities.

The secret property is being used in various parts of the codebase, including storage, retrieval, and network requests, indicating proper integration. Ensure thorough testing as suggested in the review comment to maintain security and functionality.

  • Source/ARTLocalDevice.m: Setting and storing the secret.
  • Source/ARTNSMutableRequest+ARTPush.m: Using the secret for device authentication.
  • Source/ARTJsonLikeEncoder.m: Including the secret in dictionary representation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `secret` property with existing functionalities.

# Test: Search for the usage of the `secret` property. Expect: Proper handling and usage in the codebase.
rg --type objc -A 5 $'secret'

Length of output: 7124

Test/Test Utilities/NSObject+TestSuite.h (1)

34-34: Approve the addition of the tryInObjC function.

The introduction of the tryInObjC function is a valuable addition for structured error handling in Objective-C. Ensure that the function is correctly implemented and used throughout the codebase.

The code changes are approved.

Run the following script to verify the correct implementation and usage of the tryInObjC function:

Source/ARTDeviceDetails.m (1)

3-3: Approve the import of the ARTDeviceDetails+Private.h file.

The import of ARTDeviceDetails+Private.h is a positive change for improving modularity and maintainability of the ARTDeviceDetails class. Ensure that the integration of this import with existing functionalities is thoroughly tested.

The code changes are approved.

Run the following script to verify the integration of the new import:

Test/Test Utilities/NSObject+TestSuite.m (1)

52-60: Well-implemented error handling mechanism.

The tryInObjC function correctly encapsulates a non-escaping block within a try-catch structure, adhering to Objective-C's error handling conventions. This addition enhances the error handling capabilities of the SDK.

The implementation is approved as it meets the requirements and follows best practices.

Source/Ably.modulemap (1)

39-39: Approval of header file additions with a documentation reminder.

The inclusion of ARTChannelOptions+Private.h and ARTDeviceDetails+Private.h in the module map is appropriate for enhancing SDK functionality. Ensure that these files are well-documented to clarify their purpose and usage.

The changes are approved, but it's recommended to update the documentation accordingly.

Also applies to: 47-47

Source/ARTChannel.m (1)

3-3: Good practice enforced, but ensure compatibility.

Setting _options.frozen = YES; during initialization enforces immutability, which is generally a good practice to prevent unintended side effects. However, ensure that this change is thoroughly tested to verify that it does not adversely affect existing functionalities where options might have been modified post-initialization.

The changes are approved, but thorough testing is recommended.

Also applies to: 26-26

Test/Tests/RealtimeClientChannelTests.swift (1)

4790-4826: Ensure immutability of ARTRealtimeChannelOptions after instantiation.

The test method test__140__ChannelOptions__options_provided_when_instantiating_a_channel_should_be_frozen is designed to verify that once ARTRealtimeChannelOptions are used to instantiate a channel, they become immutable. This is confirmed by attempting to modify the cipher, modes, and params properties of channelOptions after the channel has been instantiated, which correctly raises NSExceptionName.objectInaccessibleException.

The test method is correctly implemented and follows good testing practices by checking for exceptions when trying to modify frozen objects.

@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 30, 2024 11:12 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 30, 2024 11:15 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f9684a5 and 4952663.

Files selected for processing (1)
  • Source/ARTAuth.m (1 hunks)
Files skipped from review due to trivial changes (1)
  • Source/ARTAuth.m

@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 30, 2024 12:40 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 30, 2024 12:43 Inactive
…etails`) as `readonly`. Redeclared them as `readwrite` in a private interface.
@maratal maratal force-pushed the fix/1962-swift-concurrency-annotations branch from eba2bfd to 58ccb88 Compare August 30, 2024 13:35
@github-actions github-actions bot temporarily deployed to staging/pull/1963/features August 30, 2024 13:36 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc August 30, 2024 13:40 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
Source/ARTChannel.m (1)

26-26: Approved setting of _options.frozen.

Setting _options.frozen to YES during initialization is a good practice to ensure immutability and thread safety. It would be beneficial to add a comment explaining why this change is necessary, especially for future maintainers or developers unfamiliar with the concurrency requirements.

Consider adding a comment in the code to explain the purpose of setting _options.frozen to YES, to enhance code readability and maintainability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eba2bfd and 58ccb88.

Files selected for processing (17)
  • Ably.xcodeproj/project.pbxproj (10 hunks)
  • Source/ARTAuth.m (1 hunks)
  • Source/ARTChannel.m (2 hunks)
  • Source/ARTChannelOptions.m (2 hunks)
  • Source/ARTDeviceDetails.m (1 hunks)
  • Source/ARTJsonLikeEncoder.m (1 hunks)
  • Source/ARTLocalDevice.m (1 hunks)
  • Source/ARTRealtimeChannelOptions.m (1 hunks)
  • Source/Ably.modulemap (1 hunks)
  • Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h (1 hunks)
  • Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h (1 hunks)
  • Source/include/Ably/ARTDeviceDetails.h (1 hunks)
  • Source/include/Ably/ARTLocalDevice.h (2 hunks)
  • Test/Test Utilities/NSObject+TestSuite.h (1 hunks)
  • Test/Test Utilities/NSObject+TestSuite.m (1 hunks)
  • Test/Tests/RealtimeClientChannelTests.swift (2 hunks)
Files skipped from review due to trivial changes (6)
  • Source/ARTAuth.m
  • Source/ARTJsonLikeEncoder.m
  • Source/ARTLocalDevice.m
  • Source/Ably.modulemap
  • Source/PrivateHeaders/Ably/ARTDeviceDetails+Private.h
  • Source/include/Ably/ARTLocalDevice.h
Files skipped from review as they are similar to previous changes (10)
  • Ably.xcodeproj/project.pbxproj
  • Source/ARTChannelOptions.m
  • Source/ARTDeviceDetails.m
  • Source/ARTRealtimeChannelOptions.m
  • Source/PrivateHeaders/Ably/ARTChannelOptions+Private.h
  • Source/PrivateHeaders/Ably/ARTLocalDevice+Private.h
  • Source/include/Ably/ARTDeviceDetails.h
  • Test/Test Utilities/NSObject+TestSuite.h
  • Test/Test Utilities/NSObject+TestSuite.m
  • Test/Tests/RealtimeClientChannelTests.swift
Additional comments not posted (1)
Source/ARTChannel.m (1)

3-3: Approved import statement.

The addition of ARTChannelOptions+Private.h is necessary for accessing private properties or methods that are likely used in the initialization logic.

@umair-ably
Copy link
Contributor

LGTM once @lawrence-forooghian is happy with the open conversation

@lawrence-forooghian
Copy link
Collaborator

lawrence-forooghian commented Sep 3, 2024

Looks good, I just want to test it out in Chat to check that it makes our warnings go away, will do that shortly

Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like ARTRealtimeChannels isn't marked as sendable. Please could you address that and have another check of everything to make sure there isn't anything else missed?

@github-actions github-actions bot temporarily deployed to staging/pull/1963/features September 3, 2024 15:19 Inactive
@maratal
Copy link
Collaborator Author

maratal commented Sep 3, 2024

It seems like ARTRealtimeChannels isn't marked as sendable. Please could you address that and have another check of everything to make sure there isn't anything else missed?

Made a quick check and added private interface to ARTDevicePushDetails as well. Also made it sendable. I'll need Xcode 16 for a proper review of all warnings, so let me know if you find anything else before that.

@github-actions github-actions bot temporarily deployed to staging/pull/1963/jazzydoc September 3, 2024 15:24 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58ccb88 and 7ae9700.

Files selected for processing (8)
  • Ably.xcodeproj/project.pbxproj (11 hunks)
  • Source/ARTDevicePushDetails.m (1 hunks)
  • Source/ARTJsonLikeEncoder.m (1 hunks)
  • Source/Ably.modulemap (1 hunks)
  • Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h (1 hunks)
  • Source/include/Ably/ARTDeviceDetails.h (1 hunks)
  • Source/include/Ably/ARTDevicePushDetails.h (1 hunks)
  • Source/include/Ably/ARTRealtimeChannels.h (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • Ably.xcodeproj/project.pbxproj
  • Source/ARTJsonLikeEncoder.m
  • Source/Ably.modulemap
Additional comments not posted (16)
Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h (3)

1-2: LGTM!

The code changes are approved.


4-4: LGTM!

The code changes are approved.


8-14: LGTM!

The code changes are approved.

Source/ARTDevicePushDetails.m (1)

2-3: Approve the changes to the import statements.

The changes to the import statements, including the addition of the import for ARTDevicePushDetails+Private.h, are approved.

Verify that the use of private methods or properties does not introduce any unintended side effects or break the public API contract.

The use of a private category can enhance encapsulation and allow the class to access more specialized features or internal logic. However, it is important to ensure that the use of private methods or properties does not introduce any unintended side effects or break the public API contract.

Please confirm that the use of private methods or properties in ARTDevicePushDetails+Private.h does not introduce any unintended side effects or break the public API contract.

Source/include/Ably/ARTDevicePushDetails.h (4)

10-10: LGTM!

The NS_SWIFT_SENDABLE annotation is correctly added to the ARTDevicePushDetails interface, indicating that instances can be safely used across Swift concurrency contexts. This aligns with the PR objective of enhancing compatibility with Swift's concurrency model.


16-16: LGTM!

The recipient property is correctly changed to read-only, which enforces encapsulation by preventing direct modification from outside the class. This is a good practice to manage mutability, especially since the property type is NSMutableDictionary.


21-21: LGTM!

The state property is correctly changed to read-only, which enforces encapsulation by preventing direct modification from outside the class.


26-26: LGTM!

The errorReason property is correctly changed to read-only, which enforces encapsulation by preventing direct modification from outside the class.

Source/include/Ably/ARTRealtimeChannels.h (1)

20-20: LGTM!

The addition of the NS_SWIFT_SENDABLE annotation to the ARTRealtimeChannels interface is a valuable change that enhances the usability and safety of the class in Swift applications that utilize structured concurrency features. This annotation indicates that instances of the class can be safely used across Swift concurrency domains, helping to prevent concurrency-related issues and providing clarity for Swift developers.

The change does not alter the existing functionality of the class but adds a layer of safety and interoperability with Swift's concurrency model. This is a positive improvement that aligns with the objectives outlined in the linked issue and contributes to the overall robustness and usability of the SDK.

The code change is approved.

Source/include/Ably/ARTDeviceDetails.h (7)

11-11: LGTM!

The NS_SWIFT_SENDABLE annotation is correctly added to the ARTDeviceDetails class, indicating that instances can be safely used across Swift concurrency domains. This change aligns with the PR objective of enhancing compatibility with Swift's concurrency model.


17-17: LGTM!

Changing the access level of the id property to read-only is a good practice. It enhances encapsulation by preventing external modification of the property after its initial assignment, thereby promoting immutability and potentially improving thread safety.


22-22: LGTM!

Changing the access level of the clientId property to read-only is a good practice. It enhances encapsulation by preventing external modification of the property after its initial assignment, thereby promoting immutability and potentially improving thread safety.


27-27: LGTM!

Changing the access level of the platform property to read-only is a good practice. It enhances encapsulation by preventing external modification of the property after its initial assignment, thereby promoting immutability and potentially improving thread safety.


32-32: LGTM!

Changing the access level of the formFactor property to read-only is a good practice. It enhances encapsulation by preventing external modification of the property after its initial assignment, thereby promoting immutability and potentially improving thread safety.


37-37: LGTM!

Changing the access level of the metadata property to read-only is a good practice. It enhances encapsulation by preventing external modification of the property after its initial assignment, thereby promoting immutability and potentially improving thread safety.


42-42: LGTM!

Changing the access level of the push property to read-only is a good practice. It enhances encapsulation by preventing external modification of the property after its initial assignment, thereby promoting immutability and potentially improving thread safety.

…iceDetails` and `ARTDevicePushDetails` sendable.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ae9700 and dc8f168.

Files selected for processing (7)
  • Ably.xcodeproj/project.pbxproj (11 hunks)
  • Source/ARTDevicePushDetails.m (1 hunks)
  • Source/ARTJsonLikeEncoder.m (1 hunks)
  • Source/Ably.modulemap (1 hunks)
  • Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h (1 hunks)
  • Source/include/Ably/ARTDeviceDetails.h (1 hunks)
  • Source/include/Ably/ARTDevicePushDetails.h (1 hunks)
Files skipped from review due to trivial changes (4)
  • Ably.xcodeproj/project.pbxproj
  • Source/ARTJsonLikeEncoder.m
  • Source/Ably.modulemap
  • Source/PrivateHeaders/Ably/ARTDevicePushDetails+Private.h
Files skipped from review as they are similar to previous changes (2)
  • Source/ARTDevicePushDetails.m
  • Source/include/Ably/ARTDevicePushDetails.h
Additional comments not posted (7)
Source/include/Ably/ARTDeviceDetails.h (7)

11-11: LGTM!

The NS_SWIFT_SENDABLE annotation is correctly added to the ARTDeviceDetails class interface, indicating that instances of the class can be safely used across Swift concurrency contexts. This change aligns with the PR objective of enhancing the compatibility of the SDK with Swift's concurrency model.


17-17: LGTM!

The access level of the id property is correctly changed to readonly, preventing external modification after its initial assignment. This change enhances encapsulation and promotes immutability, potentially improving thread safety.


22-22: LGTM!

The access level of the clientId property is correctly changed to readonly, preventing external modification after its initial assignment. This change enhances encapsulation and promotes immutability, potentially improving thread safety.


27-27: LGTM!

The access level of the platform property is correctly changed to readonly, preventing external modification after its initial assignment. This change enhances encapsulation and promotes immutability, potentially improving thread safety.


32-32: LGTM!

The access level of the formFactor property is correctly changed to readonly, preventing external modification after its initial assignment. This change enhances encapsulation and promotes immutability, potentially improving thread safety.


37-37: LGTM!

The access level of the metadata property is correctly changed to readonly, preventing external modification after its initial assignment. This change enhances encapsulation and promotes immutability, potentially improving thread safety.


42-42: LGTM!

The access level of the push property is correctly changed to readonly, preventing external modification after its initial assignment. This change enhances encapsulation and promotes immutability, potentially improving thread safety.

@lawrence-forooghian
Copy link
Collaborator

Tested again in Chat and there are no warnings now. Still might be some types that Chat isn't using that aren't covered here, but I’m happy to approve and address other needs if we discover them.

@maratal maratal merged commit 01e425d into main Sep 5, 2024
7 checks passed
@maratal maratal deleted the fix/1962-swift-concurrency-annotations branch September 5, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add Swift concurrency annotations
3 participants